﻿@model List<CMP.ERP.Model.ClientMessage>
@{
    Layout = null;
}

@Html.Action("Account_Show", "Account");
    <div class="content">
    <div class="header">
        <div class="header-right">

            <form method="post" action="/Client/Custom_Info_Add">
                <div id="modal-container-973559" class="modal hide fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="width:400px; margin-left:-150px;">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                        <h3 id="myModalLabel">
                            客户新增系统
                        </h3>
                    </div>
                    <div class="modal-body">

                        <table class="table table-hover table-bordered " style="width:400px;text-align:center;margin:0 auto;border:2px solid #428bca;">

                            <tbody>
                                <tr>
                                    <td>客户名称:</td>
                                    <td><input type="text" name="Client_Name" required /></td>
                                </tr>
                                <tr>
                                    <td>手机号:</td>
                                    <td><input type="text" name="Client_Phone" required /></td>
                                </tr>
                                <tr>
                                    <td>地址:</td>
                                    <td><input type="text" name="Client_Address" required /></td>
                                </tr>
                                <tr>
                                    <td>邮箱:</td>
                                    <td><input type="text" name="Client_Email" required /></td>
                                </tr>
                                <tr>
                                    <td>备注:</td>
                                    <td><textarea id="TextArea1" rows="2" cols="20" name="Client_Remark"></textarea></td>
                                </tr>
                                <tr>
                                    <td>省份</td>
                                    <td>
                                        <select id="ppfor" name="P_Id">

                                        </select>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="modal-footer">
                        <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button> <button type="submit" class="btn btn-default"><span class="icon-inbox"></span>保存</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <!-- 顶部 -->

    <div id="middle">

        <div class="Switch"></div>
        <script type="text/javascript">
            $(document).ready(function (e) {
                $(".Switch").click(function () {
                    $(".left").toggle();
                });
            });
        </script>

        <div class="right" id="mainFrame">

            <div class="right_cont">
                <ul class="breadcrumb">
                    当前位置：
                    <a href="/Home/Index">首页</a>
                    <span class="divider">/</span>
                    客户管理
                </ul>
                    <div class="title_right"><strong>客户管理</strong></div>
                <div style="width:100%;">
                        <form action="/Client/Serach_Custom_Info" method="get" text-align:center">
                            <table>
                                <tr>
                                    <td>客户名称:</td>
                                    <td><input type="text" name="Client_Name"  /></td>
                                    <td><button type="submit" class="btn btn-default" style="border-bottom:10px;"><span class="icon-search"></span>查询 </button></td>
                                    <td><button id="modal-973559" href="#modal-container-973559" role="button" type="button" class="btn btn-default" data-toggle="modal" style="border-bottom:10px;"><span class="icon-plus"></span>新增</button></td>
                                    <td><button id="Button1" href="#modal-container-973559" role="button" type="button" class="btn btn-default" style="border-bottom:10px;" onclick="DeleteSelectItem()">批量删除</button></td>
                                </tr>
                            </table>
                        </form>
                    </div>
                    <div style="margin-top:20px;">
                            <table class="table  table-hover table-bordered table-striped" style="margin-left:10px">
                            <thead>
                                <tr>
                                    <th style="text-align:center"><input id="Checkbox1" type="checkbox" onclick="selectAll()" value="全选" /></th>
                                    <th style="text-align:center">客户编码</th>
                                    <th style="text-align:center">客户名称</th>
                                    <th style="text-align:center">手机号</th>
                                    <th style="text-align:center">地址</th>
                                    <th style="text-align:center">邮箱</th>
                                    <th style="text-align:center">备注</th>
                                    <th style="text-align:center">省份</th>
                                    <th style="text-align:center">操作</th>
                                </tr>
                            </thead>
                            <tbody>
                               @foreach (var i in Model)
                                {
                                    <tr>
                                        <td style="text-align:center"><input id="Checkbox1" type="checkbox" name="ClientId" value="@i.Client_Id" /></td>
                                        <td style ="text-align:center">@i.Client_Id</td>
                                        <td style="text-align:center">@i.Client_Name</td>
                                        <td style="text-align:center">@i.Client_Phone</td>
                                        <td style="text-align:center">@i.Client_Address</td>
                                        <td style="text-align:center">@i.Client_Email</td>
                                        <td style="text-align:center">@i.Client_Remark</td>
                                        <td style="text-align:center">@((ViewBag.P_Id as List<CMP.ERP.Model.Province>).Where(p=>p.P_Id==i.P_Id).FirstOrDefault().P_Name)</td>
                                        <td><a href="/Client/Custom_Info_Upt/@i.Client_Id" style="color:black"><span class="icon-edit"></span>更新</a>
                                        <a href="/Client/Custom_Del/@i.Client_Id" onclick="return confirm('真的要删除吗？')"><span class="icon-remove"></span>删除</a></td>
                                    </tr>
                                }
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 底部 -->
    <script>
        !function () {
            laydate.skin('molv');
            laydate({ elem: '#Calendar' });
        }();

            function fun() {
                location.href = '/Home/Index';
            }
        </script>
<script>
    $(function () {
        $.ajax({
            url: "/Client/GetCitySelect",
            type: "get",
            success: function (d) {
                //添加下拉框元素
                $(d).each(function (index, item) {
                    //拼接 元素
                    var option = "<option value='" + item.P_Id+ "'>" + item.P_Name + "</option>";
                    $("#ppfor").append(option);
                });
            }
        })
    })
    //全选 全不选
    function selectAll() {
        //判断是否全选
        if ($("#Checkbox1").attr("checked") == "checked") {
            $("[name='ClientId']").attr("checked", "checked");
        }
        else {
            $("[name='ClientId']").removeAttr("checked");
        }
    }
    //删除 异常调用C#方法
    function DeleteSelectItem() {
        var selectVale = "";

        //查找所有选中的复选框元素
        var Userlist = $("[name = 'ClientId']:checked");
        $(Userlist).each(function (index, user) {
            if (selectVale.length > 0) {
                selectVale += ",";
            }
            selectVale += $(user).val();
        })
        $.ajax({
            url: '/Client/DeleteAll',
            type: "get",
            data: "Client_Id=" + selectVale,
            success: function (mes) {
                if (mes) {
                    alert('删除成功！！！！');
                    //刷新显示数据
                    location.reload();
                }
            }
        });
    }
</script>


